package com.example.demofdfs.example.queue;

import java.util.Date;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;

public class DelayQueueTest {

	public static void main(String[] args) throws InterruptedException {
		BlockingQueue<TaskDelayed> queue = new DelayQueue<>();
		queue.put(new TaskDelayed(new Task(5, "ssss", System.currentTimeMillis() + 9000L)));
		queue.put(new TaskDelayed(new Task(2, "ssss", System.currentTimeMillis() + 6000L)));
		queue.put(new TaskDelayed(new Task(3, "ssss", System.currentTimeMillis() + 7000L)));
		queue.put(new TaskDelayed(new Task(1, "ssss", System.currentTimeMillis() + 5000L)));
		queue.put(new TaskDelayed(new Task(4, "ssss", System.currentTimeMillis() + 8000L)));
		
		for(;;) {
			System.out.println(queue.take().getTask() + "----" + new Date());
		}
	}

}
